<<<<<<< .mine
function gcd_rec(a, b) {
    if (b) {
        return gcd_rec(b, a % b);
    } else {
        return Math.abs(a);
    }
}
				
function angle(p1x, p1y, p2x, p2y) {
    if(((Math.atan2(p1y - p2y, p1x - p2x)) * 180 / Math.PI) > 0){
        return 360 - ((Math.atan2(p1y - p2y, p1x - p2x)) * 180 / Math.PI);
    }else{
        return -((Math.atan2(p1y - p2y, p1x - p2x)) * 180 / Math.PI);
    }

}

function JednotkovaKruznica(x,y,uhol,uholR){
            
    this.x = x;
    this.y = y;
    this.uhol = uhol;
    this.uholRucicky = uholR;
    const RADIUS = 80;
    Sprite.apply(this);
    this.buttonMode = true;
    this.mouseChildren = false;
    this.drag = false;
    this.clickedX;
    this.clickedY;
                
    this.graphics.beginFill(white);
    this.graphics.drawCircle(x, y, RADIUS);
                
    this.graphics.beginFill(black);
    this.graphics.lineStyle(2,black,1);
    this.graphics.moveTo(x,y);
    this.graphics.lineTo(x,y+RADIUS);
    this.graphics.moveTo(x,y);
    this.graphics.lineTo(x,y-RADIUS);
    this.graphics.moveTo(x,y);
    this.graphics.lineTo(x+RADIUS,y);
    this.graphics.moveTo(x,y);
    this.graphics.lineTo(x-RADIUS,y);
	
    var pi = "\u03C0";
    var gcd = gcd_rec(uhol,180);
    var uholRad = "";
    if(uhol != gcd){
        uholRad = uhol/gcd;
    }
    uholRad += pi;
    if(gcd != 180){
        uholRad += "/" + (180/gcd);
    }
				
    var uholText = new TextField();
    uholText.setTextFormat(new TextFormat(font, 20, black));
    uholText.text = uholRad;
    uholText.width = 100; 
    uholText.height = uholText.textHeight;
    uholText.x = x - 20; 
    uholText.y = y - RADIUS - 30;
    this.addChild(uholText);
                
    var uholText2 = new TextField();
    uholText2.setTextFormat(new TextFormat(font, 15, black));
    uholText2.text = this.uholRucicky + "°";
    uholText2.width = 100; 
    uholText2.height = uholText2.textHeight;
    uholText2.x = x+Math.cos(-(this.uholRucicky*Math.PI)/180)*RADIUS; 
    uholText2.y = y+Math.sin(-(this.uholRucicky*Math.PI)/180)*RADIUS;
    this.addChild(uholText2);
		        
    this.isOK = isOK;
    function isOK(){
        if (this.uhol == this.uholRucicky){
            return true;
        }
        return false;
    }
                
    var rucicka = new Sprite();
               
    rucicka.graphics.lineStyle(2,red,1);
    rucicka.graphics.moveTo(x,y);
    rucicka.graphics.lineTo(x+Math.cos(-(this.uholRucicky*Math.PI)/180)*RADIUS,y+Math.sin(-(this.uholRucicky*Math.PI)/180)*RADIUS);
		        
    this.addChild(rucicka);
                
    this.mouseDown = mouseDown;
    function mouseDown(e){
        
        e.target.drag = true;
        e.target.clickedY = e.target.stage.mouseY;
                	
        e.target.uholRucicky = Math.round(angle(e.target.stage.mouseX, e.target.stage.mouseY,x,y));
                	
        rucicka.graphics.clear();
        rucicka.graphics.moveTo(x,y);
        rucicka.graphics.lineTo(x+Math.cos(-(e.target.uholRucicky*Math.PI)/180)*RADIUS,y+Math.sin(-(e.target.uholRucicky*Math.PI)/180)*RADIUS);
                    
        uholText2.x = x+Math.cos(-(e.target.uholRucicky*Math.PI)/180)*RADIUS; 
        uholText2.y = y+Math.sin(-(e.target.uholRucicky*Math.PI)/180)*RADIUS;
        uholText2.text = e.target.uholRucicky + "°";
                
    }
                
    this.mouseUp = mouseUp;
    function mouseUp(e){        	
        e.target.drag = false;
        e.target.parent.isSolved();
    }
                
    this.move = move;
    function move(e){
                	
        if(e.target.drag == true){
                    	
            e.target.uholRucicky = Math.round(angle(e.target.stage.mouseX, e.target.stage.mouseY,x,y));
                    	
            rucicka.graphics.clear();
            rucicka.graphics.moveTo(x,y);
            rucicka.graphics.lineTo(x+Math.cos(-(e.target.uholRucicky*Math.PI)/180)*RADIUS,y+Math.sin(-(e.target.uholRucicky*Math.PI)/180)*RADIUS);
                    
            uholText2.x = x+Math.cos(-(e.target.uholRucicky*Math.PI)/180)*RADIUS; 
            uholText2.y = y+Math.sin(-(e.target.uholRucicky*Math.PI)/180)*RADIUS;
            uholText2.text = e.target.uholRucicky + "°";
                
        }else{
                    	
        }
                    
    }
                
    this.mouseOut = mouseOut;
    function mouseOut(e){	
        e.target.drag = false;
    }
                
    this.addEventListener(MouseEvent.MOUSE_DOWN,this.mouseDown);
    this.addEventListener(MouseEvent.MOUSE_UP,this.mouseUp);
    this.addEventListener(MouseEvent.MOUSE_MOVE,this.move);
    this.addEventListener(MouseEvent.MOUSE_OUT,this.mouseOut);

}
JednotkovaKruznica.prototype = new Sprite();=======
function gcd_rec(a, b) {
    if (b) {
        return gcd_rec(b, a % b);
    } else {
        return Math.abs(a);
    }
}
				
function angle(p1x, p1y, p2x, p2y) {
    if(((Math.atan2(p1y - p2y, p1x - p2x)) * 180 / Math.PI) > 0){
        return 360 - ((Math.atan2(p1y - p2y, p1x - p2x)) * 180 / Math.PI);
    }else{
        return -((Math.atan2(p1y - p2y, p1x - p2x)) * 180 / Math.PI);
    }

}

function JednotkovaKruznica(x,y,uhol,uholR){
            
    this.x = x;
    this.y = y;
    this.uhol = uhol;
    this.uholRucicky = uholR;
    const RADIUS = 80;
    Sprite.apply(this);
    this.buttonMode = true;
    this.mouseChildren = false;
    this.drag = false;
    this.clickedX;
    this.clickedY;
                
    this.graphics.beginFill(white);
    this.graphics.drawCircle(x, y, RADIUS);
                
    this.graphics.beginFill(black);
    this.graphics.lineStyle(2,black,1);
    this.graphics.moveTo(x,y);
    this.graphics.lineTo(x,y+RADIUS);
    this.graphics.moveTo(x,y);
    this.graphics.lineTo(x,y-RADIUS);
    this.graphics.moveTo(x,y);
    this.graphics.lineTo(x+RADIUS,y);
    this.graphics.moveTo(x,y);
    this.graphics.lineTo(x-RADIUS,y);
	
    var pi = "\u03C0";
    var gcd = gcd_rec(uhol,180);
    var uholRad = "";
    if(uhol != gcd){
        uholRad = uhol/gcd;
    }
    uholRad += pi;
    if(gcd != 180){
        uholRad += "/" + (180/gcd);
    }
				
    var uholText = new TextField();
    uholText.setTextFormat(new TextFormat(font, 20, black));
    uholText.text = uholRad;
    uholText.width = 100; 
    uholText.height = uholText.textHeight;
    uholText.x = x - 20; 
    uholText.y = y - RADIUS - 20;
    this.addChild(uholText);
                
    var uholText2 = new TextField();
    uholText2.setTextFormat(new TextFormat(font, 10, black));
    uholText2.text = this.uholRucicky + "°";
    uholText2.width = 100; 
    uholText2.height = uholText2.textHeight;
    uholText2.x = x+Math.cos(-(this.uholRucicky*Math.PI)/180)*RADIUS; 
    uholText2.y = y+Math.sin(-(this.uholRucicky*Math.PI)/180)*RADIUS;
    this.addChild(uholText2);
		        
    this.isOK = isOK;
    function isOK(){
        if (this.uhol == this.uholRucicky){
            return true;
        }
        return false;
    }
                
    var rucicka = new Sprite();
               
    rucicka.graphics.lineStyle(2,red,1);
    rucicka.graphics.moveTo(x,y);
    rucicka.graphics.lineTo(x+Math.cos(-(this.uholRucicky*Math.PI)/180)*RADIUS,y+Math.sin(-(this.uholRucicky*Math.PI)/180)*RADIUS);
		        
    this.addChild(rucicka);
                
    this.mouseDown = mouseDown;
    function mouseDown(e){
        
        e.target.drag = true;
        e.target.clickedY = mouseY;
                	
        e.target.uholRucicky = Math.round(angle(mouseX, mouseY,x,y));
                	
        rucicka.graphics.clear();
        rucicka.graphics.moveTo(x,y);
        rucicka.graphics.lineTo(x+Math.cos(-(e.target.uholRucicky*Math.PI)/180)*RADIUS,y+Math.sin(-(e.target.uholRucicky*Math.PI)/180)*RADIUS);
                    
        uholText2.x = x+Math.cos(-(e.target.uholRucicky*Math.PI)/180)*RADIUS; 
        uholText2.y = y+Math.sin(-(e.target.uholRucicky*Math.PI)/180)*RADIUS;
        uholText2.text = e.target.uholRucicky + "°";
                
    }
                
    this.mouseUp = mouseUp;
    function mouseUp(e){
                	
        e.target.drag = false;
    }
                
    this.move = move;
    function move(e){
                	
        if(e.target.drag == true){
                    	
            e.target.uholRucicky = Math.round(angle(mouseX, mouseY,x,y));
                    	
            rucicka.graphics.clear();
            rucicka.graphics.moveTo(x,y);
            rucicka.graphics.lineTo(x+Math.cos(-(e.target.uholRucicky*Math.PI)/180)*RADIUS,y+Math.sin(-(e.target.uholRucicky*Math.PI)/180)*RADIUS);
                    
            uholText2.x = x+Math.cos(-(e.target.uholRucicky*Math.PI)/180)*RADIUS; 
            uholText2.y = y+Math.sin(-(e.target.uholRucicky*Math.PI)/180)*RADIUS;
            uholText2.text = e.target.uholRucicky + "°";
                
        }else{
                    	
        }
                    
    }
                
    this.mouseOut = mouseOut;
    function mouseOut(e){	
        e.target.drag = false;
    }
                
    this.addEventListener(MouseEvent.MOUSE_DOWN,this.mouseDown);
    this.addEventListener(MouseEvent.MOUSE_UP,this.mouseUp);
    this.addEventListener(MouseEvent.MOUSE_MOVE,this.move);
    this.addEventListener(MouseEvent.MOUSE_OUT,this.mouseOut);

}
JednotkovaKruznica.prototype = new Sprite();>>>>>>> .r36
